package com.lagou.sale.dao;

import com.lagou.sale.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface OrderDao {
    @Insert("insert ignore into lagou_order (order_id, item_num, create_time, is_paid) " +
            "values (${orderId}, ${itemNum}, now(), ${isPaid})")
    int createOrder(Order order);

    @Update("update lagou_order set is_paid=2 where order_id=#{0} and is_paid=0")
    int dropOrder(long orderId);

    @Update("update lagou_order set is_paid=1 where order_id=#{0} and is_paid=0")
    int payOrder(long orderId);

}
